package com.kk.state;

/**
 * @author o_o
 * @date 2022-06-20
 */
public class RaffleActivity {
    private final State noRaffleState = new NoRaffle(this);
    private final State canRaffleState = new CanRaffle(this);
    private final State dispenseState = new DispenseRaffle(this);
    private final State dispenseOutState = new DispenseOutRaffle(this);
    private int count;
    private State state;

    /**
     * 初始化奖品数量
     *
     * @param count
     */
    public RaffleActivity(int count) {
        this.setState(getNoRaffleState());
        this.count = count;
    }

    /**
     * 扣积分
     */
    public void reduceMoney() {
        state.deductMoney();
    }

    public void raff() {
        //中奖，领取奖品
        if (state.raffle()) {
            state.dispensePrize();
        }
    }


    public State getState() {
        return state;
    }

    public void setState(State state) {
        this.state = state;
    }

    public State getNoRaffleState() {
        return noRaffleState;
    }

    public State getCanRaffleState() {
        return canRaffleState;
    }

    public State getDispenseState() {
        return dispenseState;
    }

    public State getDispenseOutState() {
        return dispenseOutState;
    }

    public int getCount() {
        return count--;
    }

    public void setCount(int count) {
        this.count = count;
    }
}
